home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_02 / allison / prepend.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-30  |  565 b   |  33 lines

  1. LISTING 9 - Illustrates the use of prepend
  2. #include <stdio.h>
  3. #include <assert.h>
  4.  
  5. #define WIDTH 11
  6.  
  7. extern int prepend(char *, unsigned, char *);
  8.  
  9. main()
  10. {
  11.     char s[WIDTH+1];
  12.     int offset = WIDTH;
  13.  
  14.     s[offset] = '\0';
  15.     offset = prepend(s,offset,"three");
  16.     assert(offset >= 0);
  17.     puts(s+offset);
  18.  
  19.     offset = prepend(s,offset,"two");
  20.     assert(offset >= 0);
  21.     puts(s+offset);
  22.  
  23.     offset = prepend(s,offset,"one");
  24.     assert(offset >= 0);
  25.     puts(s+offset);
  26.     return 0;
  27. }
  28.  
  29. /* Output:
  30. three
  31. twothree
  32. onetwothree
  33.